/* ----------------------------------------------------------------------------
* File: api_proxy.h
*
* Desc: Proxy to Skype API
*
* Created: 03/05/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _API_PROXY_H_
#define _API_PROXY_H_

#include "logger.h"
#include "exception.h"
#include "thread_wrapper.h"
#include "utils.h"

#import "Skype4COM.dll" named guids

namespace SkypeProtection
{
	class APIProxy
		: public Common::ThreadWrapper
	{
	private:
		APIProxy(const APIProxy&);
		APIProxy& operator=(const APIProxy&);
	public:
		explicit APIProxy(bool registerAPI)
			throw(Common::Exception);
		~APIProxy();

		// ThreadWrapper implementation
		virtual Common::Error Run();

		virtual Common::Error RunLogic(SKYPE4COMLib::ISkype* skype) = 0;

		Common::Error Start();
		Common::Error Stop();

	private:
		bool IsExistFile(const char* FileName);
		void RegisterAPILibrary();
		SKYPE4COMLib::ISkypePtr CreateCOMInstance();

		bool registerAPI;
		HANDLE m_StartEvent;

	protected:
		std::auto_ptr<Common::Logger> m_Logger;
	};
}


#endif // _SKYPE_PROXY_H_